/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package eu.easyedu.dictionary.api.options;

import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.swing.JComponent;
import org.netbeans.spi.options.OptionsPanelController;
import org.openide.util.HelpCtx;
import org.openide.util.Lookup;

/**
 *
 * @author hlavki
 */
public class DictionaryOptionsPanelController extends OptionsPanelController {

    private boolean changed;
    private DictionaryOptionsPane optionsPane;
    private DictionaryOptions opts;
 
    public DictionaryOptionsPanelController() {
        optionsPane = new DictionaryOptionsPane();
        changed = false;
 
        opts = DictionaryOptions.getInstance();
        opts.addPropertyChangeListener(new PropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent evt) {
                changed = true;
            }
        });
    }
 
    /** {@inheritDoc} */
    public void update() {
//        optionsPane.refreshOptions();
    }
 
    /** {@inheritDoc} */
    public void applyChanges() {
//        optionsPane.applyChanges();
        changed = false;
    }
 
    /** {@inheritDoc} */
    public void cancel() {
        // do nothing
    }
 
    /** {@inheritDoc} */
    public boolean isValid() {
        return true;
    }
 
    /** {@inheritDoc} */
    public boolean isChanged() {
        return changed;
    }
 
    /** {@inheritDoc} */
    public JComponent getComponent(Lookup masterLookup) {
        return optionsPane;
    }

    @Override
    public HelpCtx getHelpCtx() {
        return new HelpCtx ("eu.easyedu.dictionary.options.DictionaryOptionsPanelController");
    }

    @Override
    public void addPropertyChangeListener(PropertyChangeListener l) {
        opts.addPropertyChangeListener(l);
    }

    @Override
    public void removePropertyChangeListener(PropertyChangeListener l) {
        opts.removePropertyChangeListener(l);
    }

}
